$(function() {

	var team_name = null;
	var team_id = null;
	var myteam_main=null;
	var radiovalue=null;
	var idValue=null;

	var now = new Date();
	var date=now.getDate();
	var print_day = now.getDate() + 7; // ����源뚯�留��먮즺瑜�戮묐뒗��
	var print_year = now.getYear();
	var print_month = now.getMonth();
	
	var team_id_nba_array=["79926","79929","79930","79937","79938","79939","79940","79942","79943","79946","79949","79952","79953","79955","79956","79928",
	                       "79931","79932","79933","79934","79935","79936","79941","79944","79945","79947","79948","79950","79951","79954"];
	var team_name_nba_array=["샬럿 밥캣츠","토론토 랩터스","워싱턴 위져즈","필라델피아 76's","올랜도 매직","브루클린 네츠","뉴욕 닉스","밀워키 벅스",
	                         "마이애미 히트","인디애나 페이서스","디트로이트 피스톤즈","클리블랜드 캐벌리어스","시카고 불스","보스턴 셀틱스","애틀란타 호크스",
	                         "맴피스 그리즐리스","유타 재즈","오클라호마 시티 썬더","샌안토니오 스퍼스","새크라멘토 킹스","포틀랜드 트레일 블레이저스","피닉스 선즈",
	                         "미네소터 팀버울브스","LA 레이커스","LA 클리퍼스","골든스테이트 워리어스","휴스턴 로키츠","덴버 너기츠","댈러스 매버릭스","뉴올리언스 펠리컨스"];

	var team_id_epl_array=["1319","1321","246","247","249","250","251","252","253","254","258","260","261","262","264","271","274","283","302","316"];
	var team_name_epl_array=["웨스트 브로미치 앨비언 FC", "뉴캐슬 유나이티드  FC", "맨체스터 유나이티드 FC", 
	                         "아스널 FC", "토트넘 홋스퍼 FC", "애스턴 빌라 FC", "첼시 FC", "애버턴 FC", 
	                         "리버풀 FC", "웨스트 햄 유나이티드 FC", "맨체스터 시티 FC", 
	                         "풀럼 FC","선덜랜드 AFC", "헐 시티 AFC", "스토크 시티 FC", "사우스햄튼 FC", 
	                         "크리스탈 팰리스","노리치 시티 FC","스완지 시티 AFC","카디프 시티 FC"]; 

	var url_year = '&game_year=' + (print_year + 1900);
	var url_month = '&game_month=' + (print_month + 1) + '&type=list';
	var url_team = null;
	var url_total = null;
	var url_schedule = null;
	var url_rank = null;
	var idVal =null;
	var value=null;
	
	//var ajax_url = "http://70.12.110.72:3000";
	
	
	setLocalMyteam();
	
	setMyTeam (localStorage.getItem('teamId'));
	
	function setMyTeam(teamId){
		if(parseInt(teamId/10000)==7){
			setMyNbaTeam(teamId);
		}else{
			setMyEplTeam(teamId);
		}
		
	}	

	var grid_cnt3=0;
	var grid_cnt4=0;
	
	$(".myteam_grid3").click(function(){
		if(grid_cnt3==0){
		$(".myteam_grid4").css("width", "0").css("height", "0");
		$(".myteam_grid3").css("width", "98%").css("transition", "0.2s");
		grid_cnt3=1;
		}else{
		$(".myteam_grid4").css("width", "49%");
		$(".myteam_grid3").css("width", "49%").css("transition", "0.2s");
		grid_cnt3=0;
		}		
	});
	$(".myteam_grid4").click(function(){
		if(grid_cnt4==0){
		$(".myteam_grid3").css("width", "0").css("height", "0");
		$(".myteam_grid4").css("width", "98%").css("transition", "0.2s");
		grid_cnt4=1;
		}else{
		$(".myteam_grid3").css("width", "49%");
		$(".myteam_grid4").css("width", "49%").css("transition", "0.2s");
		grid_cnt4=0;
		}		
	});	
	
	
	$('#btn_save').on('click',function() {
					$("#disp_team2").empty();
					$("#disp_main_team").empty();
					$("#disp_main_team2").empty();
					$(".chatteams").empty();
					radiovalue = $('input[name="radio"]:checked').val();
					idValue=(parseInt(radiovalue/10000));
					team_id=radiovalue;
					localStorage.setItem("teamId",team_id);
					
					if(idValue==7){
						localStorage.setItem('category','nba');
						settingNba(radiovalue);
					}else{
						localStorage.setItem('category','epl');
						settingEpl(radiovalue);
					}
	});
	
	
	$('.myTeamIcon').on('click',function(){
		
		$('#disp_main_team2').empty();
		idVal =localStorage.getItem("teamId");
		value=parseInt((idVal/10000));
		if (value==7){
			setMyNbaTeam(localStorage.getItem("teamId"));
		}else{
			setMyEplTeam(localStorage.getItem("teamId"));	
		}
	});
	
	function settingNba(radiovalue){
		for(var i=0; i<team_id_nba_array.length; i++){
			if(team_id_nba_array[i]==radiovalue){
				
				img_source=radiovalue+".gif";
				$("#disp_team2").append("<img src=./img/nba/"+img_source+'>');
				$("<img src=./img/nba/"+img_source+'>').appendTo('#disp_main_team');
				team_name=team_name_nba_array[i];
				$('<span id="my_team_text"/>').text(team_name)
										.appendTo($('#disp_team2'));
				
				$('<h3 id="my_team_h3"/>').text(team_name)
										.appendTo($('#disp_main_team'));
				
				localStorage.setItem("myTeam",team_name);
				localStorage.setItem("myTeamImg",img_source);
			}
			
		}
		setMyNbaTeam(localStorage.getItem('teamId'));
	}
	
	function settingEpl(raidovalue){
		for(var i=0; i<team_id_epl_array.length; i++){
			
			if(team_id_epl_array[i]==radiovalue){
				img_source=radiovalue+".gif";
			
				$("<img src=./img/epl/"+img_source+'>').appendTo('#disp_main_team');
				team_name=team_name_epl_array[i];
				$('<span id="my_team"/>').text(team_name)
										.appendTo($('#disp_team2'));
				$("#disp_team2").append("<img src=./img/epl/"+img_source+'>');
				$('<h3 id="my_team_h3"/>').text(team_name)
										.appendTo($('#disp_main_team'));
				
				localStorage.setItem("myTeam",team_name);
				localStorage.setItem("myTeamImg",img_source);
			}
		}
		setMyEplTeam(localStorage.getItem('teamId'));
	}

	
	function setMyNbaTeam(teamId){//setNbaTeam or setEplTeam
		url_team = '?team_id=' + localStorage.getItem("teamId");
		//console.log(url_team);

		url_schedule = 'tinf_schres.daum';
		url_rank = 'tinf_main.daum';

		url_total = 'http://sports.media.daum.net/basketball/nba/record/'
				+ url_schedule
				+ url_team
				+ url_year
				+ url_month;
		url_total_rank = 'http://sports.media.daum.net/basketball/nba/record/'
				+ url_rank + url_team;
		//console.log(url_total);
		
		$.mobile.showPageLoadingMsg("d","LOADING");
		$.ajax({
			url : ajax_url+'/nba_rank',
			data : {
				url : url_total_rank
			},
			complete: function(){
	        	 $.mobile.hidePageLoadingMsg();
	         },
			success : function(data) {
				//console.log(team_name);
				//console.log("where"+team_name);
				$('#tbody_result').empty();
				$('#tbody_rank').empty();
				var rank = $(data).find('.tbl,.kbl_team_info_season');
				$('#thead_rank').empty();
	        	var thead_rank_tr = $('#thead_rank').append('<tr>');
	        	var tbody_rank_tr = $('#tbody_rank').append('<tr>');
	        	
	        	$('<th class="team_ranking">').text('순위').appendTo(thead_rank_tr);
	        	$('<th class="team_win">').text('승').appendTo(thead_rank_tr);
	        	$('<th class="team_loss">').text('무').appendTo(thead_rank_tr);
	        	$('<th class="team_wpct">').text('패').appendTo(thead_rank_tr);
	        	$('<th class="team_gb">').text('득점').appendTo(thead_rank_tr);
	        	
				var text_rank = rank.find('.last').find('.rank').text();
				var text_win = rank.find('.last').find('.win').text();
				var text_loss = rank.find('.last').find('.loss').text();
				var text_wpct = rank.find('.last').find('.wpct').text(); // �밸쪧
				var text_gb = rank.find('.last').find('.gb').text(); // �뱀감
				
				$('<td id="team_ranking">').text(text_rank)
						.appendTo(tbody_rank_tr);
				$('<td id="team_win">').text(text_win)
						.appendTo(tbody_rank_tr);
				$('<td id="team_loss">').text(text_loss)
						.appendTo(tbody_rank_tr);
				$('<td id="team_wpct">').text(text_wpct)
						.appendTo(tbody_rank_tr);
				$('<td id="team_gb">').text(text_gb).appendTo(
						tbody_rank_tr);

				
				var recent = $(data).find('.nba_recent_match');
				//$('#tbody_result').append('<tr>');
				$('#thead_result').empty();		
				$('#tbody_result').empty();
				/*var thead_result_tr = $('<tr>').appendTo('#thead_result');
				var tbody_result_tr = $('<tr>').appendTo('#tbody_result');
				$('<th>').text('날짜').appendTo(thead_result_tr);
			    $('<th>').text('팀').appendTo(thead_result_tr);
			    $('<th>').text('경기시간').appendTo(thead_result_tr);*/
				
				var result_date = recent.find(
						'tbody>tr:first-child').find('.date')
						.text();
				var result_team = recent.find(
						'tbody>tr:first-child').find(
						'.team1, .score, .team2').text();
				/*var result_time = recent.find(
						'tbody>tr:first-child').find('.time')
						.text();*/

				console.log('date: '+result_date);
				$('<span id="result_date">'+result_date+'</span><br>').appendTo('#tbody_result');
				/*				$('<span id="result_date">').text(result_date)
								.appendTo('#tbody_result');
				*/				$('<span id="result_team">').text(result_team)
								.appendTo('#tbody_result');
				/*$('<td id="result_date">').text(result_date)
						.appendTo(tbody_result_tr);
				$('<td id="result_team">').text(result_team)
						.appendTo(tbody_result_tr);
				$('<td id="result_time">').text(result_time)
						.appendTo(tbody_result_tr);*/
				
				/**************nba players*************************/
				img_player1=teamId+"01.jpg";
				img_player2=teamId+"02.jpg";
				img_player3=teamId+"03.jpg";		

				$('#tbody_player').empty();
				$('#thead_player').empty();
				var players = $(data).find('.team_player_record');
				
				$('#tbody_player').append('<tr>');
				$('#tbody_player').append('<tr>');
				$('#tbody_player').append('<tr>');
			
				var pts_name = players.find('.pts').find('.name').text();
				var pts_num = players.find('.pts').find('.num').text();
				var ast_name = players.find('.ast').find('.name').text();
				var ast_num = players.find('.ast').find('.num').text();
				var reb_name = players.find('.reb').find('.name').text();
				var reb_num = players.find('.reb').find('.num').text();
			   	
			   	var thead_player_tr = $('#thead_player').append('<tr>');
			   
				
				$('<th id="player_score" style="border-right:1px solid #bbb;">').text('득점').appendTo(thead_player_tr);
				$('<th id="player_assist" style="border-right:1px solid #bbb;">').text('어시스트').appendTo(thead_player_tr);
				$('<th id="player_rebound">').text('리바운드').appendTo(thead_player_tr);
				
				var tr1 = $('<tr id="tr_player"/>').appendTo($('#tbody_player'));
			   	var tr2 = $('<tr/>').appendTo($('#tbody_player'));
			   	var tr3 = $('<tr/>').appendTo($('#tbody_player'));
		   	
		   	
			/*$("<img src=/img/nba/"+img_source+'>').appendTo('#disp_main_team');*/
		  		$('<td id="best_person"><img src=/img/nba/players/'+img_player1+' style="width:95px; height:110px;"></td>').appendTo(tr1);
		   		$('<td id="best_person" style="font-weight:bold;">').text(pts_name).appendTo(tr2);
				$('<td id="best_score" style="font-weight:bold; color:red;"> ').text(pts_num).appendTo(tr3);
				
				$('<td id="best_person"><img src=/img/nba/players/'+img_player2+' style="width:95px; height:110px;"></td>').appendTo(tr1);
				$('<td id="best_person" style="font-weight:bold;">').text(ast_name).appendTo(tr2);
				$('<td id="best_score" style="font-weight:bold; color:blue;"> ').text(ast_num).appendTo(tr3);
				
				$('<td id="best_person"><img src=/img/nba/players/'+img_player3+' style="width:95px; height:110px;"></td>').appendTo(tr1);
				$('<td id="best_person" style="font-weight:bold;">').text(reb_name).appendTo(tr2);
				$('<td id="best_score" style="font-weight:bold; color:green;"> ').text(reb_num).appendTo(tr3);
		/************************************************************************************/
			}
		});
		
		$.mobile.showPageLoadingMsg("d","로딩중");
		$.ajax({
			url : ajax_url+'/new_schedule',
			data : {
				url : url_total
				},
			complete: function(){
	        	 $.mobile.hidePageLoadingMsg();
	         },																	
			success : function(data) {
				var realrank = $(data).find(
						'.record_calendar_list');
				var cnt = 0;

				// 留덉씠��寃쎄린�쇱젙(�쇱＜��
				realrank.find('.today, .fast')
						.each(function(idx, item) {

						var text_date = $(item).find('.date').text();
						var text_num = parseInt(text_date);//�좎쭨�먯꽌 �レ옄留��곕줈 類�蹂�닔

						if (text_num > print_day)
							return;

						var text_team = $(item).find('.team1, .vs, .team2')
								.text(); //怨쇨굅寃뚯엫
						var text_team2 = $(item).find('.team').text(); //誘몃옒寃뚯엫
						var text_time = $(item).find('.time').text();
						var text_place = $(item).find('.stadium').text();

						if (text_team) {//�앸궃 �ㅻ뒛寃쎄린
							text_date = " ";
							text_team2 = " ";
							text_time = " ";
							text_place = " ";
						} else {//���앸궃 寃쎄린(�ㅻ뒛+誘몃옒)
							if (text_team2) {//*****�섏젙 : 媛�슫���뺣젹�섏뼱 �붾㈃���쒖떆��
								$('.schedule').empty();
								$('<span>'+ text_date+ "  " +  text_time+ '</span><br/>').appendTo('.schedule');
								$('<span>'+  text_team2+  '</span><br/>').appendTo('.schedule');
								if (cnt === 0) {//硫붿씤�섏씠吏�留덉씠��諛붾줈 �ㅼ쓬 寃쎄린留�異쒕젰)
//									$('<span>'+ text_date+ "  "+ text_team2+ "  "+ text_time+ '</span>').appendTo('#disp_main_team2');
									$('<p class="main_dday">'+ "D-DAY  "+(parseInt(text_date)-date)+ '</p>').appendTo('#disp_main_team2');
									$('<p class="main_team2">'+  text_team2+ '</p>').appendTo('#disp_main_team2');
									$('<p class="main_date" style="border-radius: 0 0 13px 0;">'+  text_date+"  "+ text_time + '</p>').appendTo('#disp_main_team2');
									console.log('idx : '+ idx);
									cnt++;	
								}
							}
						}
					});
				if(realrank.find('.today > .team1').text()){
					var team1=realrank.find('.today>.team1>a').text();
					var team2=realrank.find('.today>.team2>a').text();
					chatOpen(team1,team2);
				}else if(realrank.find('.today > .team ').text()){
					var team=realrank.find('.today>.team').text();
					chatOpenTeam(team);
				}else if(realrank.find('.today>.no_match').text()){
					chatNo();
				}
				
					}//success
				});//ajax
		
	}
	
	function setMyEplTeam(teamId){
		url_team= '?team_id='+localStorage.getItem("teamId");
		url_schedule = 'tinf_schres.daum';
		url_rank = 'tinf_main.daum';
		url_total = 'http://sports.media.daum.net/worldsoccer/all/record/'+ url_schedule + url_team + url_year + url_month;
		url_total_rank = 'http://sports.media.daum.net/worldsoccer/all/record/'+ url_rank + url_team;
		$.ajax({
			url : ajax_url+'/nba_rank',
	        data : {url : url_total_rank},
	        complete: function(){
	        	 $.mobile.hidePageLoadingMsg();
	         },
	        success : function(data){
	        	//�뱁뙣
	        	var epl_rank =$(data).find('.tbl, .kl_team_info_season');
	        	$('#thead_rank').empty();
	        	$('#tbody_rank').empty();
	        	var thead_rank_tr = $('#thead_rank').append('<tr>');
	        	var tbody_rank_tr = $('#tbody_rank').append('<tr>');
		        
	        	var text_erank = epl_rank.find('tbody :first-child').find('.k_rank').text();
	        	var text_ewin = epl_rank.find('tbody :first-child').find('.win_qty').text(); 
	        	var text_etie = epl_rank.find('tbody :first-child').find('.tie_qty').text(); 
	        	var text_elose = epl_rank.find('tbody :first-child').find('.lose_qty').text(); //�밸쪧
	        	var text_egoal = epl_rank.find('tbody :first-child').find('.gain_goal').text(); //�뱀감
		        
	        	$('<th class="team_ranking">').text('순위').appendTo(thead_rank_tr);
	        	$('<th class="team_win">').text('승').appendTo(thead_rank_tr);
	        	$('<th class="team_loss">').text('무').appendTo(thead_rank_tr);
	        	$('<th class="team_wpct">').text('패').appendTo(thead_rank_tr);
	        	$('<th class="team_gb">').text('득점').appendTo(thead_rank_tr);
	        	
		        $('<td id="team_ranking">').text(text_erank).appendTo(tbody_rank_tr);
			    $('<td id="team_win">').text(text_ewin).appendTo(tbody_rank_tr);
			    $('<td id="team_loss">').text(text_etie).appendTo(tbody_rank_tr);
			    $('<td id="team_wpct">').text(text_elose).appendTo(tbody_rank_tr);
			    $('<td id="team_gb">').text(text_egoal).appendTo(tbody_rank_tr);
			    
			    //理쒓렐 寃쎄린 寃곌낵
			    var recent = $(data).find('.team_info_recent_match_kl');
			    $('#thead_result').empty();
			    $('#tbody_result').empty();
			    
			    var thead_result_tr = $('<tr>').appendTo('#thead_result');
			    var tbody_result_tr1 = $('<tr>').appendTo('#tbody_result');
			    var tbody_result_tr2 = $('<tr>').appendTo('#tbody_result');
			    $('<th class="result_team">').text('팀').appendTo(thead_result_tr);
			    $('<th class="result_score">').text('득점').appendTo(thead_result_tr);
			    $('<th class="result_remark">').text('득점상황').appendTo(thead_result_tr);
	        	
	    		var result_team1 =recent.find('tbody>tr:first-child').find('.team').text(); 
	        	var result_score1 =recent.find('tbody>tr:first-child').find('.goal_qty').text();
	        	var result_remark1 =recent.find('tbody>tr:first-child').find('.remark').html(); 

	        	var result_team2 =recent.find('.last').find('.team').text(); 
	        	var result_score2 =recent.find('.last').find('.goal_qty').text();
	        	var result_remark2 =recent.find('.last').find('.remark').html(); 
				
	        	console.log('team : '+result_team1+'score : '+result_score1+'remark : '+result_remark1);
	        	
			    $('<td>').text(result_team1).appendTo(tbody_result_tr1);
			    $('<td>').text(result_score1).appendTo(tbody_result_tr1);
			    $('<td>').html(result_remark1).appendTo(tbody_result_tr1);
			    
			    $('<td>').text(result_team2).appendTo(tbody_result_tr2);
			    $('<td>').text(result_score2).appendTo(tbody_result_tr2);
			    $('<td>').html(result_remark2).appendTo(tbody_result_tr2);
			    
			    
			    /*******************epl player*************************************/

				$('#tbody_player').empty();
				$('#thead_player').empty();
				var players = $(data).find('.team_player_record');
				
				$('#tbody_player').append('<tr>');
				$('#tbody_player').append('<tr>');
				var pts_name = players.find('.el_goal').find('.name').text();
				var pts_num = players.find('.el_goal').find('.num').text();
				var pts_img = players.find('.el_goal').find('dd>a>img').attr('src');
				var ast_name = players.find('.el_assist').find('.name').text();
				var ast_num = players.find('.el_assist').find('.num').text();
				var ast_img = players.find('.el_assist').find('dd>a>img').attr('src');
				console.log('img : '+pts_img);
				console.log('img : '+ast_img);
				
		           	var thead_player_tr = $('#thead_player').append('<tr>');
		           	//var tbody_player_tr = $('#tbody_player').append('<tr>');
		        	
		        	$('<th id="player_score" style="border-right:1px solid #bbb;">').text('팀내 득점 1위').appendTo(thead_player_tr);
		        	$('<th id="player_assist">').text('팀내 도움 1위').appendTo(thead_player_tr);
		        	
		           	var tr1 = $('<tr/>').appendTo($('#tbody_player'));
		           	var tr2 = $('<tr/>').appendTo($('#tbody_player'));
		           	var tr3 = $('<tr/>').appendTo($('#tbody_player'));
		           	
		           	$('<td id="best_img1">').append($('<img style="width:95px; height:110px;"/>').attr('src',pts_img)).appendTo(tr1);
		   			$('<td id="best_person1" style="font-weight:bold;">').text(pts_name).appendTo(tr2);
		   			$('<td id="best_score1" style="font-weight:bold; color:red;"> ').text(pts_num).appendTo(tr3);
		   			
		   			$('<td id="best_img2">').append($('<img style="width:95px; height:110px;"/>').attr('src',ast_img)).appendTo(tr1);
		   			$('<td id="best_person2" style="font-weight:bold;">').text(ast_name).appendTo(tr2);
		   			$('<td id="best_score2" style="font-weight:bold; color:blue;"> ').text(ast_num).appendTo(tr3);

		/********************************************************************************/
			    
			    
	        }
		});	

		$.mobile.showPageLoadingMsg("d","로딩중");
		$.ajax({
			url : ajax_url+'/new_schedule',
	        data : {url : url_total},
	        complete: function(){
	        	 $.mobile.hidePageLoadingMsg();
	         },
	        success : function(data){
	        	var realrank =$(data).find('tbody');
	        	var cnt=0;

	    	    //留덉씠��寃쎄린�쇱젙(�쇱＜��
		        realrank.find('.today, .fast').each(function(idx,item){
		        	
		        	var text_date =$(item).find('.date').text();
	         	  	var text_num = parseInt(text_date);//�좎쭨�먯꽌 �レ옄留��곕줈 類�蹂�닔
	         	  	
	           	
	         	  	if(text_num>print_day) return;
	           
	         	  	var text_team =$(item).find('.team1, .vs, .team2').text(); //怨쇨굅寃뚯엫 
	         	  	var text_team2 =$(item).find('.team').text(); //誘몃옒寃뚯엫
	           		var text_time =$(item).find('.time').text(); 
	           		var text_place =$(item).find('.stadium').text();
	           		console.log('text_team : '+text_team);
	 				console.log('text_team2 : '+text_team2);
	 				console.log('text_time : '+text_time);
	 				console.log('text_place : '+text_place);
	 				console.log('idx : '+idx);
	           		
	           		if(text_team){//�앸궃 �ㅻ뒛寃쎄린
	           			console.log('past');
	               		text_date = " ";
	               		text_team2 = " ";
	               		text_time = " ";
	               		text_place = " ";
	               	}else{//���앸궃 寃쎄린(�ㅻ뒛+誘몃옒)
	               		console.log('fast');
	               		if(text_team2){//*****�섏젙 : 媛�슫���뺣젹�섏뼱 �붾㈃���쒖떆��
	               			$('.schedule').empty();
	               			$('<span>'+ text_date+ "  " +  text_time+ '</span><br/>').appendTo('.schedule');
							$('<span>'+  text_team2+  '</span><br/>').appendTo('.schedule');
		         			if(cnt==0){//硫붿씤�섏씠吏�留덉씠��諛붾줈 �ㅼ쓬 寃쎄린留�異쒕젰)
		         				//$('<span>'+text_date+"  "+text_team2+"  "+text_time+'</span>').appendTo('#disp_main_team2');
		         				$('<p class="main_dday">'+ "D-DAY  "+(parseInt(text_date)-date)+ '</p>').appendTo('#disp_main_team2');
		         				$('<p class="main_team2">'+  text_team2+ '</p>').appendTo('#disp_main_team2');
								$('<p class="main_date">'+  text_date+"  "+ text_time + '</p>').appendTo('#disp_main_team2');
		         				cnt++;
		         			}
	               		}
	               	} 
		        });
		        if(realrank.find('.today > .team1').text()){
					var team1=realrank.find('.today>.team1>a').text();
					var team2=realrank.find('.today>.team2>a').text();
					chatOpen(team1,team2);
				}else if(realrank.find('.today > .team ').text()){
					var team=realrank.find('.today>.team').text();
					chatOpenTeam(team);
				}else if(realrank.find('.today>.no_match').text()){
					chatNo();
				}
	        }//success
	         
		});//ajax
		
		
	}

	
	
	function setLocalMyteam(){
		
		$('<h3>'+localStorage.getItem("myTeam")+'<h3>').appendTo("#disp_main_team");
		$('<h3>'+localStorage.getItem("myTeam")+'<h3>').appendTo("#disp_team2");
		$('<img src=./img/'+localStorage.getItem("category")+"/"+localStorage.getItem("myTeamImg")+'>').appendTo("#disp_main_team");
		$('<img src=./img/'+localStorage.getItem("category")+"/"+localStorage.getItem("myTeamImg")+'>').appendTo("#disp_team2");
		//$('<span id="hihi">'+ localStorage.getItem("myteam_main"+date)+ '</span>').appendTo('#disp_main_team');
		
	
	}
});